

import {createApi} from "@reduxjs/toolkit/query/react";
import useBaseQuery from "@/hooks/useBaseQuery";
import { stringify } from "qs";

export const contentManageApi = createApi({
    reducerPath:'contentManageApi',
    baseQuery:useBaseQuery('mm'),
    endpoints(build) {
      return {
        getList:build.query({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/list',
              method:"get",
              params:data,
              openErrMessage: true
            }
          },
        }),
        getLanguageList:build.query({
          query:(data:any) => {
            return {
              url: 'mmContent/get_languages',
              method:"get",
              params:data,
              openErrMessage: true
            }
          },
        }),
        translate:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/translate',
              method:"post",
              body:data,
              openErrMessage: true
            }
          },
        }),
        smsReminder:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/smsReminder',
              method:"post",
              body:data,
              openErrMessage: true
            }
          },
        }),
        qwReminder:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/qwReminder',
              method:"post",
              body:data,
              openErrMessage: true
            }
          },
        }),
        copy:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/copy',
              method:"post",
              body:data,
              openErrMessage: true
            }
          },
        }),
        getTagList:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePubGroup/list?pageNo=1&pageSize=200',
              method:"post",
              params:data,
              openErrMessage: true
            }
          },
        }),
        addGroup:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePubGroup/add',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        editGroup:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePubGroup/edit',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        batchGrouping:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/batchGrouping',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        deletContent:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/delete?id=' + data.id,
              method:"delete",
              openErrMessage: true
            }
          },
        }),
        editContentText:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/edit',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        getAccountAssignList:build.query({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/selectAccountAssignList',
              method:"get",
              params:data,
              openErrMessage: true
            }
          },
        }),
        assignAccount:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/assignAccount',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        deleteBatch:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/deleteBatch?ids=' + data.ids,
              method:"delete",
              body: data,
              openErrMessage: true
            }
          },
        }),
        deleteGroup:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePubGroup/deleteByIds?ids=' + data.ids,
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        detectingSensitive:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/detectingSensitive',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        getGroupTemplateList:build.query({
          query:(data:any) => {
            return {
              url: 'aicreation/getGroupTemplateList',
              method:"get",
              params:data,
              openErrMessage: true
            }
          },
        }),
        addContent:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/add',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        deleteProjectRelation:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmContentManagePub/deleteProjectRelation',
              method:"post",
              body: data,
              openErrMessage: true
            }
          },
        }),
        getFeeLogList:build.query({
          query:(data:any) => {
            return {
              url: 'mmFeeLog/list',
              method:"get",
              params: data,
              openErrMessage: true
            }
          },
        }),
        getPayList: build.query({
          query(data) {
            return {
              url:'pay/list',
              method:"get",
              params: data,
              openErrMessage: true
            }
          },
        }),
      }
    }
});

export const {
    useGetListQuery,
    useGetLanguageListQuery,
    useTranslateMutation,
    useSmsReminderMutation,
    useQwReminderMutation,
    useCopyMutation,
    useGetTagListMutation,
    useAddGroupMutation,
    useEditGroupMutation,
    useBatchGroupingMutation,
    useDeletContentMutation,
    useEditContentTextMutation,
    useGetAccountAssignListQuery,
    useAssignAccountMutation,
    useDeleteBatchMutation,
    useDeleteGroupMutation,
    useDetectingSensitiveMutation,
    useGetGroupTemplateListQuery,
    useAddContentMutation,
    useDeleteProjectRelationMutation,
    useGetFeeLogListQuery,
    useGetPayListQuery,
} = contentManageApi;
